package com.example.myapplication.login;

import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.widget.LinearLayout;

import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.Fragment;

import com.example.myapplication.MainActivity;
import com.example.myapplication.R;
import com.example.myapplication.b_entity.Login_Entity;

public  class User_Activity extends AppCompatActivity implements Login_Fragment.GetType {


    private LinearLayout mainLin;
    private Fragment fragment1;
    private Fragment fragment2;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_user_);
        initView();
    }

    private void initView() {
        mainLin = (LinearLayout) findViewById(R.id.main_lin);
        Reg_Fragment reg_fragment = new Reg_Fragment();
        fragment1 = new Login_Fragment();
        fragment2 = new Reg_Fragment();
        getSupportFragmentManager().beginTransaction().add(R.id.main_lin, fragment2).commit();
        getSupportFragmentManager().beginTransaction().add(R.id.main_lin, fragment1).commit();

    }


    @Override
    public void Type(int i) {
        switch (i) {

            case 1:
                if (fragment1!=null){
                    getSupportFragmentManager().beginTransaction().show(fragment2).commit();
                    getSupportFragmentManager().beginTransaction().hide(fragment1).commit();

                }
                break;
            case 2:
                if (fragment2!=null){
                    getSupportFragmentManager().beginTransaction().show( fragment1).commit();
                    getSupportFragmentManager().beginTransaction().hide(fragment2).commit();
                }
                break;
            case 3:
                startActivity(new Intent(User_Activity.this, MainActivity.class));
                break;
        }
    }
}
